/***************************************************************************
 *   Copyright (C) 2007 by Grzegorz Latarowski, Maciej Gajewski            *
 *   g.latarowski@gmail.com                                                *
 *   maciej.gajewski0@gmail.com                                            *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/




 

#ifndef GPARAMDESCRIPTION_H
#define GPARAMDESCRIPTION_H


// Qt
#include <QString>
#include <QVariant>
#include <QList>
#include <QStringList>

// gparams
#include "gparams.h"

// gcommon
#include "gxmlelement.h"



// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
class GParamDescription : public GXmlDocument
{
	
public:
	// ====================================================
	// constructor/desctructor
	
	GParamDescription();
	virtual ~GParamDescription() {}
	
	// ====================================================
	// xml element 	
	
	virtual QDomElement toXml( QDomDocument & doc )const;
	
	virtual void fromXml( const QDomElement & domElement );

	virtual QString documentType()const { return QObject::tr( "ParamDescription" ); }

	// ====================================================
	// param description specific
	
	QString name()const { return _name; }
	QVariant::Type type()const { return _type; }
	QString readableName()const { return _readableName; }
	QVariant defaultValue()const { return _defaultValue; }
	
	void setName( const QString & name ) { _name = name; }
	void setType( const QVariant::Type type ) { _type = type; }
	void setReadableName( const QString & readableName ) { _readableName = readableName; }
	void setDefaultValue( const QVariant & defaultValue ) { _defaultValue = defaultValue; }
	
	// ====================================================
	// param editor specific 
	
	QVariant minimum() const { return _minimum; }
	QVariant maximum() const { return _maximum; }
	QVariant singleStep() const { return _singleStep; }
	int decimals() const { return _decimals; }
	const GParams& items() const { return _items; }
	QStringList itemNames()const { return _items.keys(); }
	QVariant itemValue( const QString& name )const { return _items[ name ]; }
	QString valueName( const QVariant& value ) { return _items.key( value ); }
	
	void setMinimum( const QVariant & minimum ) { _minimum = minimum; }
	void setMaximum( const QVariant & maximum ) { _maximum = maximum; }
	void setSingleStep( const QVariant & singleStep ) { _singleStep = singleStep; }
	void setDecimals( const int decimals ) { _decimals = decimals; }
	void setItems( const GParams & items ) { _items = items; }
	void setItem( const QString& name, const QVariant& value ) { _items[ name ] = value; }
	
private:
	QString        _name;
	QString        _readableName;
	QVariant::Type _type;
	QVariant       _defaultValue;
	
	QVariant     _minimum;
	QVariant     _maximum;
	QVariant     _singleStep;
	int          _decimals;
	GParams      _items;
	

}; // class !GParamDescription
// ---------------------------------------------------------------------------





// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
class GParamsDescription : public QList<GParamDescription>, public GXmlDocument
{
public:
	// ====================================================
	// constructor/desctructor
	
	GParamsDescription() : QList<GParamDescription>(), GXmlDocument() {}
	virtual ~GParamsDescription() {}
	
	// ====================================================
	// xml element 	
	
	virtual QDomElement toXml( QDomDocument & doc )const;
	
	virtual void fromXml( const QDomElement & element );
	virtual QString documentType()const { return QObject::tr( "ParamsDescription" ); }

	// ====================================================
	// GParamsDescription

	/// Returns default params values with names.
	GParams defaultParams()const;
	
}; // class !GParamsDescription
// ---------------------------------------------------------------------------




#endif // !GPARAMDESCRIPTION_H

// eof
